
#include "echo.hpp"


void test_Socket(const std::string &ip, in_port_t port)
{
    Socket Client;
    Client.CreateClient(port, ip);
    for (int i = 0; i < 5; ++i)
    {
        std::string str = "lueluelue!";
        Client.Send(str.c_str(), str.size());
        char buf[1024] = { 0 };
        ssize_t n = Client.Recv(buf, sizeof(buf) - 1);
        buf[n] = 0;
        std::cout << "Server says: " << buf << std::endl;
        sleep(1);
    }

    // while (1) sleep(1);

    Client.Close();
}

int main(int argc, char* argv[])
{
    if (argc != 3)
    {
        std::cerr << "Usage: " << argv[0] << " Server-IP Server-Port" << std::endl;
        return 0;
    }
    std::string ip(argv[1]);
    in_port_t port = std::stoi(argv[2]);

    EnableScreen();

    test_Socket(ip, port);
    return 0;
}